package com.heima.behavior.controller.v1;

import com.heima.behavior.service.ApBehaviorService;
import com.heima.model.behavior.dto.LikesBehaviorDto;
import com.heima.model.behavior.dto.ReadDto;
import com.heima.model.behavior.dto.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/")
public class BehaviorController {
    @Autowired
    private ApBehaviorService apBehaviorService;

    /**
     * 点赞功能
     * @param dto
     * @return
     */
    @PostMapping("/likes_behavior")
    public ResponseResult likeBehavior(@RequestBody LikesBehaviorDto dto){
        return apBehaviorService.likeBehavior(dto);
    }

    /**
     * 喜欢不喜欢功能
     * @param dto
     * @return
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikeBehavior(@RequestBody UnLikesBehaviorDto dto){
        return apBehaviorService.unLikeBehavior(dto);
    }

    /**
     * 统计阅读次数
     * @param dto
     * @return
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadDto dto){
        return apBehaviorService.readBehavior(dto);
    }
}
